<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .father {
            width: 400px;
            height: 400px;
            background-color: skyblue;
            margin: 100px;
            overflow: hidden;
            position: relative;
        }

        .son {
            width: 150px;
            height: 150px;
            background-color: purple;
            /* 测试定位 */
            position: absolute;
            left: 10px;
            top: 10px;
        }
    </style>
    <script src="jquery.min.js"></script>
</head>
<body>
    <div class="father">father
        <div class="son">son</div>
    </div>
    <script>
        // 1.返回值是一个对象
        // 2.top left:相对于整个文档的距离
        console.log($('.son').offset());
        console.log($('.son').offset()['top']);

        // 3.修改定位，参数一个对象
        $('.son').offset({
            top:200,
            left:200
        });

        // 4.获取距离：带有定位的父级，同offsetLeft offsetTop
        console.log($('.son').position());

        // 5.不能修改距离
        // $('.son').position({
        //     top:200,
        //     left:200
        // });
    </script>
</body>
</html>